import logging
import traceback
from flask import jsonify
from dao.db_connect import db_connect as db

internal_error = 500  # 服务器错误
success = 200  # 请求成功
data_missing = 101  # 数据库内无相关数据
identification_error = 100  # 未识别成功

class Virtual_Lecture(object):
    def __init__(self):
        pass

    @classmethod
    def video_msg(cls, request):
        """
        传递大v课堂的标题以及摘要
        """
        logging.debug("working on video_msg")
        code = success
        msg = "获取大v课堂信息成功"
        try:
            query_sql = f'SELECT img_url,file_url,file_name, summary FROM elite_speech LIMIT 11'
            data = db.queryAll(query_sql)
        except Exception as e:
            msg = "获取大v课堂信息失败"
            code = data_missing
            logging.debug(traceback.format_exc())
        resp = {
            "data": data,
            "msg": msg,
            "code": code,
        }
        return jsonify(resp)

